﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using RevitProject.SpaceManager.ViewModel;

namespace RevitProject.SpaceManager.Converters
{
    public class EnumMatchToVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            // value: ViewModel 中的 CurrentView (NavView 类型)
            // parameter: XAML 中指定的要匹配的 NavView 枚举值

            if (value == null || parameter == null || !(value is NavView) || !(parameter is NavView))
            {
                return Visibility.Collapsed; // 或根据需要返回 Visibility.Hidden
            }

            NavView currentView = (NavView)value;
            NavView targetView = (NavView)parameter;

            // 如果当前视图与目标视图匹配，则可见，否则折叠
            return currentView == targetView ? Visibility.Visible : Visibility.Collapsed;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            // 通常不需要 ConvertBack 用于这种单向绑定
            throw new NotImplementedException();
        }
    }
}